package com.foreknow.mapping;

import com.foreknow.bean.Admin;

import java.util.HashMap;
import java.util.Map;

/**
 * 工厂类MappingFactory
 */
public class MappingFactory {
  private static MappingFactory mappingFactory = null;
  private Map<String, EntityMapping> maps = new HashMap<>();
  public static final String ADMIN_MAPPING = "adminMapping";
  //  public static final String USER_MAPPING = "adminMapping";

  private MappingFactory() {

  }

  public static MappingFactory getInstance() {
    if (mappingFactory == null) {
      mappingFactory = new MappingFactory();
      mappingFactory.maps.put(ADMIN_MAPPING, new AdminMapping());
      //mappingFactory.maps.put(USER_MAPPING,new UserMapping());

}
    return mappingFactory;
      }

/**
 * 根据key从Map容器中获取到xxxMapping对象
 * 哈哈
 * @param key
 * @return EntityMapping接口
 */
public EntityMapping getMap(String key) {
    return maps.get(key); //获取到AdminMapping对象
  }

}
